#!/usr/bin/bash
#
# Load T-One images and apply a workaround
#

#
# XXX: Update the name of images whose prefix is 'tone_'. Note that it is just
#      a workaround to avoid updating the config file 'docker_compose.yaml'.
#
function update_image_name
{
	typeset images=$(sudo docker images | grep -E 'tone_tone' | awk '{print $1}')
	typeset tag="latest"
	for image in $images; do
    	dst_image=${image#tone_}
        sudo docker tag $image:$tag $dst_image:$tag
        sudo docker rmi $image:$tag
    done
}

tone_images_file=${1?"*** ~/proto/data/tone/tone-images-v1030_x86.tar"}
sudo docker load -i ${tone_images_file}
update_image_name
